
#include "EmbeddedJavaVM.h"
using Pan::EmbeddedJavaVM;

#include "JvmDllLoader.h"
using Pan::JvmDll;
using Pan::JvmDllLoader;

#include "JavaVmInitArg.h"
using Pan::JavaVmInitArg;

#include <locale.h>
#include <stdio.h>

int main(int argc, char const *argv[])
{
	::setlocale(LC_ALL, "");

	::wprintf(L"你好, 测试Java虚拟机.\n");

	::wprintf(L"正在加载jvm.dll...\n");
	JvmDll jvm_dll = JvmDllLoader::loadJvmDll_pathEnv();
	if (!jvm_dll.is_valid())
	{
		::wprintf(L"加载失败!\n");
		return 0;
	}
	else
	{
		::wprintf(L"加载成功\n");
	}

	// java虚拟机初始化参数
	JavaVmInitArg vmarg(2);
	vmarg.add_option("-Djava.class.path=./hello.jar");

	EmbeddedJavaVM jvm(jvm_dll, vmarg);

	if (jvm.call_java_main("com/pan/Hello"))
	{
		::wprintf(L"ok\n");
	}
	else
	{
		::wprintf(L"error\n");
	}

	::wprintf(L"正常结束.\n");
	return 0;
}
